package com.credithc.customers.manager.controller;

import com.credithc.baseserv.core.codes.CoreCodes;
import com.credithc.baseserv.core.message.Message;
import com.credithc.baseserv.core.message.MessageFactory;
import com.credithc.customers.manager.ro.HomeRo;
import com.credithc.customers.manager.service.IHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author zhukai
 * @date 2018/12/13 15:51
 */
@RestController
@RequestMapping("/manager/yzt/v1")
public class HomeController {

    private final MessageFactory messageFactory;

    private final IHomeService homeService;

    @Autowired
    public HomeController(MessageFactory messageFactory, IHomeService homeService) {
        this.messageFactory = messageFactory;
        this.homeService = homeService;
    }

    @PostMapping("/home")
    public Message index(@RequestBody(required = false) HomeRo ro){
        Map<String, String> map = homeService.statisticsHome(ro);
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS, map);
    }

    @GetMapping("/healthCheck")
    public Message healthCheck() {
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS,"检测成功");
    }
}
